#!/usr/bin/python
# -*- coding: utf-8 -*-

""" 測試流程控制 """


def test_if(v):
	""" 用 if 測試 v 值，並印出測試結果
	"""
	if v:
		print "v:%r true !" % (v,)
	else:
		print "v:%r false !" % (v,)
# ### def test_if


test_if(True)
test_if(False)
test_if(0)
test_if(1)
test_if(2)
test_if("A")
test_if("")
test_if(())
test_if((0, 1, 2, 3,))



def test_andornot(a, b):
	if a and b:
		print "(a:%r and b:%r) is true." % (a, b,)
	else:
		print "(a:%r and b:%r) is false." % (a, b,)

	if a or b:
		print "(a:%r or b:%r) is true." % (a, b,)
	else:
		print "(a:%r or b:%r) is false." % (a, b,)

	if not a:
		print "(not a:%r) is true." % (a,)
	else:
		print "(not a:%r) is false." % (a,)

	if not b:
		print "(not b:%r) is true." % (b,)
	else:
		print "(not b:%r) is false." % (b,)
# ### def test_andornot


test_andornot(True, False)
test_andornot(0, 1)



for i in xrange(3):
	print "for i in xrange(3):", i

for i in ("a", 6, True, 9.2, None,):
	print "for i in (...):", i
else:
	print "for i in (...) - [FINALIZE]"

for i in ():
	print "for i in ():", i
else:
	print "for i in () - [FINALIZE]"



def test_while(v):
	""" 當 v > 0 時在 while 迴圈中遞減
	"""
	print "test_while(v=%r)" % (v,)
	while v > 0:
		print "while v > 0:", v
		v = v - 1
	else:
		print "while v > 0 - [FINALIZE]"
# ### def test_while


test_while(3)
test_while(0)



# vim: ts=4 sw=4 foldmethod=marker ai nowrap
